//
// Created by 62607 on 25-8-7.
//
#include <bits/stdc++.h>
using namespace std;

int a[100000];

int main() {
    srand(time(NULL));
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        a[i] = rand() % 10;
        cout << endl;
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) {
        cout << a[i] << " ";
    }
    int q;
    cin >> q;
    //binary_search(a+1, a+n+1, q );
    int k1 = lower_bound(a + 1, a + n + 1, q) - a;
    cout << k1;
    cout << endl;

    int k2 = upper_bound(a + 1, a + n + 1, q) - a;
    cout << k2;

    cout << " " << k2 - k1;

    int p=-1;
    int l = 1, r = n;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (a[mid] <= q) {
            p = mid;
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    cout <<p;

    return 0;
}
